#ifndef FORMSUB_H
#define FORMSUB_H

#include <QWidget>
#include <QDateTime>
#include <QSqlQuery>

#include "kb9000.h"

namespace Ui {
class FormSub;
}

class FormSub : public QWidget {
    Q_OBJECT

public:
    explicit FormSub(int controller_addr, int register_addr, QWidget *parent = nullptr);

    ~FormSub();
    int setData(QVector<quint16> values);    // 将串口数据解码成具体数值
    void setDescribe(QString str);
    void setTimeoutState();
    void setValus(int number, int name, int deepness, int unit, int piont, int state);


private:
    Ui::FormSub *ui;
    CARD_INFO ci;
    int fcontroller_addr, fregister_addr;
    bool used_tag = false; // 代表探测器是否在使用

    // 记录高、低、故障的旧状态，用以判断3种状态的变化
    bool  low_alarm_state_old = false,
          height_alarm_state_old = false,
          fault_state_old = false;
    float low_alarm_value_old = 0, height_alarm_value_old = 0;
//    void setValus(int number, int name, int deepness, int unit, int piont, int state);
    void dbSaveAlarm(QString desp, QString memo);

signals:
    void playWarningSound();
    void alarmDataChanged();
};

#endif // FORMSUB_H
